package ooday04;

public class Test {
    public static void main(String[] args) {
        /*
        Master master = new Master();
        Dog dog = new Dog("小黑",2,"黑");
        Fish fish = new Fish("小金",1,"金");
        Chick chick = new Chick("小黄",3,"黄");
        master.feed(dog);
        master.feed(fish);
        master.feed(chick);
         */
        Animal[] animals = new Animal[5];
        animals[0] = new Dog("小黑",8,"黑");
        animals[1] = new Dog("小灰",4,"灰");
        animals[2] = new Chick("小白",3,"白");
        animals[3] = new Chick("小黄",2,"黄");
        animals[4] = new Fish("小金",1,"金");
        for (int i=0;i< animals.length;i++){
            /*
            System.out.println(animals[i].name);
            System.out.println(animals[i].age);
            System.out.println(animals[i].colour);
            animals[i].eat();
            animals[i].drink();
             */
            if(animals[i] instanceof Dog){
                Dog dog = (Dog) animals[i];
                dog.lookHome();
                dog.swim();
            }

            if (animals[i] instanceof Fish){
                Fish fish = (Fish) animals[i];
                fish.swim();
            }
            if (animals[i] instanceof Chick){
                Chick chick =(Chick) animals[i];
                chick.layEggs();
            }

            if (animals[i] instanceof Swim){
                Swim s =(Swim) animals[i];
                s.swim();
            }
        }



























        /*
        Dog[] dogs = new Dog[3];
        dogs[0] = new Dog("小白",1,"白色");
        dogs[1] = new Dog("小黑",2,"黑色");
        dogs[2] = new Dog("小灰",3,"灰色");
        for(int i =0;i< dogs.length;i++){
            System.out.println(dogs[i].name);
            dogs[i].eat();
        }

        Chick[] chicks = new Chick[2];
        chicks[0] = new Chick("小黄",1,"黄色");
        chicks[1] = new Chick("大黑",3,"黑色");
        for (int i=0;i< chicks.length;i++){
            System.out.println(chicks[i].colour);
            chicks[i].drink();
        }

        Fish[] fish = new Fish[4];
        fish[0] = new Fish("小粉",2,"粉色");
        fish[1] = new Fish("大粉",4,"粉色");
        fish[2] = new Fish("小红",1,"红色");
        fish[3] = new Fish("大红",3,"红色");

        for (int i=0;i< fish.length;i++){
            System.out.println(fish[i].age);
            fish[i].swim();
        }

         */

    }
}
